using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Deepcode.Flux.Core.Data;

namespace Deepcode.Flux.Core.Systems.Security
{
	/// <summary>
	/// Representation of a single administration user record in Flux's database.
	/// </summary>
	public class AdministrationUser
	{
		private int _PK_ID = -1;
		private string _EmailAddress = "";
		private string _NT_Username = "";
		private string _RealName = "";
		private bool _IsSuperUser = false;

		public int PK_ID { get { return _PK_ID; } set { _PK_ID = value; } }
		public string EMailAddress { get { return _EmailAddress; } set { _EmailAddress = value; } }
		public string NT_Username { get { return _NT_Username; } set { _NT_Username = value; } }
		public string RealName { get { return _RealName; } set { _RealName = value; } }
		public bool IsSuperUser { get { return _IsSuperUser; } set { _IsSuperUser = value; } }

		public AdministrationGroup[] Groups
		{
			get
			{
				return (new AdministrationGroups()).GetGroupsForUser(PK_ID);
			}
		}


		public AdministrationUser() { }
		public AdministrationUser(DataRow RowToLoad)
		{
			_PK_ID = SQLUtility.DBNull(RowToLoad["PK_ID"], -1);
			_EmailAddress = SQLUtility.DBNull(RowToLoad["EmailAddress"], "");
			_NT_Username = SQLUtility.DBNull(RowToLoad["NT_Username"], "");
			_RealName = SQLUtility.DBNull(RowToLoad["RealName"], "");
			_IsSuperUser = SQLUtility.DBNull(RowToLoad["IsSuperUser"], false);
		}
	}
}
